package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import org.owasp.esapi.ESAPI;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.util.ApplicablePlatformEnum;
import com.frogs.system.web.exception.RequestIllegalException;
import com.frogs.system.web.api.request.Request;

/**
 * 商品评价评论请求参数类
 *
 * @author lijian
 * @version 2014年3月17日 - 下午2:03:20
 */
public class GoodsEvaluateCommentAddRequest extends Request {

	/**
	 * 账号ID
	 */
	private int userId;
	/**
	 * 商品评价ID
	 */
	private int goodsEvaluateId;
	/**
	 * 原始商品ID
	 */
	private int originalGoodsId;
	/**
	 * 商品ID
	 */
	private int goodsId;
	/**
	 * 评论内容
	 */
	private String content;
	/**
	 * 父级评论ID
	 */
	private int parentCommentId;
	/**
	 * 父级评论用户ID
	 */
	private int parentCommentUserId;
	/**
	 * 父级评论用户昵称
	 */
	private String parentCommentNickName;
	/**
	 * 适用范围
	 */
	private int applicablePlatformId;
	
	/**套餐id*/
	private Integer mealId;
	
	/** */
	public GoodsEvaluateCommentAddRequest(){
		
	}
	
	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.goodsEvaluateId = requestInfo.getIntParameter(ApiUrlParamEnum.goodsEvaluateId.getParamName(), 0);
		this.originalGoodsId = requestInfo.getIntParameter(ApiUrlParamEnum.originalGoodsId.getParamName(), 0);
		this.goodsId = requestInfo.getIntParameter(ApiUrlParamEnum.goodsId.getParamName(), 0);
		this.content = StringUtil.fixHtml(requestInfo.getParameter(ApiUrlParamEnum.content.getParamName(), ""));
		this.parentCommentId = requestInfo.getIntParameter(ApiUrlParamEnum.parentCommentId.getParamName(), 0);
		this.parentCommentUserId = requestInfo.getIntParameter(ApiUrlParamEnum.parentCommentUserId.getParamName(), 0);
		this.parentCommentNickName = requestInfo.getParameter(ApiUrlParamEnum.parentCommentNickName.getParamName(), "");
		this.applicablePlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.applicablePlatformId.getParamName(), ApplicablePlatformEnum.WEB.getId());
		this.mealId = requestInfo.getIntParameter(ApiUrlParamEnum.mealId.getParamName(), 0);
		
		if ( userId < 1 ) {
			throw new RequestIllegalException("error userId: " + userId);
		}
		if ( goodsEvaluateId < 1 ) {
			throw new RequestIllegalException("error goodsEvaluateId: " + goodsEvaluateId);
		}
		if ( originalGoodsId < 1 ) {
			throw new RequestIllegalException("error originalGoodsId: " + originalGoodsId);
		}
		if ( goodsId < 1 && mealId < 1) {
			throw new RequestIllegalException("error goodsId or mealId: " + goodsId + ","+mealId);
		}
		if ( StringUtil.isEmpty(content) ) {
			throw new RequestIllegalException("error content: " + content);
		}
		
		
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getGoodsEvaluateId() {
		return goodsEvaluateId;
	}

	public void setGoodsEvaluateId(int goodsEvaluateId) {
		this.goodsEvaluateId = goodsEvaluateId;
	}

	public int getOriginalGoodsId() {
		return originalGoodsId;
	}

	public void setOriginalGoodsId(int originalGoodsId) {
		this.originalGoodsId = originalGoodsId;
	}

	public int getGoodsId() {
		return goodsId;
	}

	public void setGoodsId(int goodsId) {
		this.goodsId = goodsId;
	}
	
	public Integer getMealId() {
		return mealId;
	}

	public void setMealId(Integer mealId) {
		this.mealId = mealId;
	}
	
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public int getParentCommentId() {
		return parentCommentId;
	}

	public void setParentCommentId(int parentCommentId) {
		this.parentCommentId = parentCommentId;
	}

	public int getParentCommentUserId() {
		return parentCommentUserId;
	}

	public void setParentCommentUserId(int parentCommentUserId) {
		this.parentCommentUserId = parentCommentUserId;
	}

	public String getParentCommentNickName() {
		return parentCommentNickName;
	}

	public void setParentCommentNickName(String parentCommentNickName) {
		this.parentCommentNickName = parentCommentNickName;
	}

	public int getApplicablePlatformId() {
		return applicablePlatformId;
	}

	public void setApplicablePlatformId(int applicablePlatformId) {
		this.applicablePlatformId = applicablePlatformId;
	}
}
